package com.heima.exceptionHandeler;

import com.heima.exception.CustomException;
import com.heima.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @RestControllerAdvice 控制器出现异常的通知类
 */
@RestControllerAdvice
public class HandlerException {

    @ExceptionHandler({
            CustomException.class
    })
    public Result handlerCustomException(CustomException e){
        e.printStackTrace();
        return new Result(false,e.getMessage());
    }

    @ExceptionHandler({
            Exception.class
    })
    public Result handlerOtherException(Exception e){
        e.printStackTrace();
        return new Result(false,"系统异常，请联系管理员");
    }

}
